home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir39
/
cmddat10.zip
/
CMDDATE.DOC
< prev
Wrap
Text File
|
1993-04-15
|
13KB
|
243 lines
Command-Date Version 1.0
RebelWare
Ronnie E. Belvin
Rt. 2 Box 210-A
Decatur, Ms. 39327
(601)635-3597
CIS 75260,1670
Command-Date is a dos utility program that can be used to
selectively execute dos commands on files selected by date. Command-Date
searches for files that match the required file path/specification.
When a matching filespec is found, Command-Date compares the file's
date with the required date. If the files date is within the range
specified, Command-Date spawns command.com with the instruction to
execute the desired dos command. Command-Date passes the file name of
the matching file to the dos command as it's first parameter. This file
will be the target of the dos command. Upon completion of the dos
command, control is returned to Command-Date and the process is repeated
until the search criteria is exhausted.
Command-Date will execute any dos executable file, .com, .exe,
.bat, internal or external, that will accept a file name as its first
command line parameter. Actually Command-Date will attempt to execute
ANY executable, once for each file that matches the search criteria, but
for it to be useful the dos executable must accept a filename as it's
first parameter and it must return control to the system when it's
finished it's task.
Command-Date will also pass any number of parameters to the
executable as it's second or greater parameter. This enables
Command-Date to work with dos commands that require multiple parameters,
such as Copy and Rename. The first parameter passed to the executable
will always be the fully qualified file name of the matching file.
The execution can be aborted at any time by pressing any key on
the keyboard except pause. The pause key will halt execution until any
other key is pressed. If the confirmation switch is used, pressing any
key will not abort the program. To abort in confirmation mode, first
select continue, then press any key.
Typing the program name with no parameters or with incorrect
parameters will display a brief help screen. The help screen is a
summary of this document and is included for a quick reference. The
essential parameters are closely checked for errors and either an
error message or the help screen will be displayed if an error is
found. Other parameters such as the command name and the additional
parameter fields have been left "loose". Command-Date simply checks for
their existence and inserts them directly into the executable command
line. This was done for versatility and it's up to you to determine the
correct parameters for these fields.
The correct command line usage of Command-Date is as follows:
Cmddate Command Filespec [Para] @+||-[Offset] [Date] [/Switch]
Command - Dos Command To Be Executed
Filespec - Path And Filename Of Files To Be Operated Upon, Wildcards Are Ok
Para - Additional Parameters That Will Be Passed Directly To Command
@+Offset - Command Will Operate Upon All Files > (Date + Offset)
@-Offset - Command Will Operate Upon All Files < (Date - Offset)
Offset - Number Of Days To Be Added OR Subtracted From The Date
Date - Date In The Form MM/DD/YY OR MM-DD-YY
/Switch - /T = Test Mode, Only Prints Commands
/S = Include Sub Directories
/C = Confirm Each Command Before Execution
/N = Answer No To Prompts
ALL PARAMETERS MUST BE SEPARATED BY A SPACE.
The Command in the command line is the name of the dos
executable to be executed. This file should be in the current directory,
in the path, or the full path name can be entered. The Filespec is the
path and filename that Command-Date will use as the search criteria. Dos
Wildcards are acceptable here and should be used the same as you would
use them with any dos command.
The Para parameters are optional to Command-Date, they are not
optional to some executable. If the executable you want to use
requires more than one parameter, enter then here. Any number of
additional parameters may entered between the Filespec and the @+ or @-
parameters and these will be passed directly to the executable as it's
second, third, fourth, ect. parameters. Copy and Rename are examples of
dos commands that require two parameters.
The @+ tells Command-Date to search for files whose file date is
greater than the Date parameter. The @- tells Command-Date to search for
files whose file date is less than the Date parameter. Command-Date uses
true greater than (>) or less than (<) comparison, not greater than or
equal to (>=), or less than or equal to (<=).
The Offset is optional and is used differently depending on
whether or not a Date parameter is entered. If the Date is not entered
the Offset must be used.If the Date is entered the offset may or may not
be used, depending on the mode of operation desired. It is always a number
of days that is added (@+) or subtracted (@-) from the Date.
The Date is the date on which comparisons will be made. It is
also optional depending on the desired mode. When the Date parameter is
used it should be in the form mm/dd/yy or mm-dd-yy.
Four switches are available. Both should be preceded by a "/"
and separated by spaces. The /T is the test mode. This switch causes
Command-Date to only display the commands that would have otherwise been
executed. This enables you to make sure that you have the command line
parameters correct before actually executing a Command-Date. The /S
switch causes Command-Date to include all sub-directories in it's search.
This is a powerful and hazardous switch. With it you can do global hard
drive deletes, copies, renames, ect. Use it with caution. Always use the
/T switch first to confirm that your parameter are all correct. The /C
switch causes Command-Date to Confirm all operations before executing
each command. The command will be displayed and you will be asked if
you want to execute this command. You may answer Y, N, or C. Yes will
cause the command to be executed, no will cause the command to be
skipped, and continue will cause Command-Date to leave the confirmation
mode and continue executing the command on the remainder of the files
that match the search criteria. The /N switch causes Command-Date to
to answer no to prompts from the executed command. It is intended to
be used with programs that ask if you want to process more files at
the end of their execution. One such program is dos's compare (comp).
Actually the "N" and a carriage return is stuffed into the keyboard
buffer before the command is executed and will answer no to the next
keyboard read. This switch requires an AT computer with an extended
(101) keyboard. The XT bios does not support the bios calls used to
implement this switch.
DATE AND OFFSET COMBINATIONS:
Omitting Both Date AND Offset Is NOT valid. Offset of zero is Not valid
Date with no Offset:
Operates upon files (greater than) or (less than) the Date.
Entering A Date With No Offset Will Cause The Command To Be Executed
Once For Each File That Is (@+) > OR (@-) < The Date.
Offset with no Date:
Operates upon files (greater than) or (less than) the (system date plus
or minus the Offset).
Entering An Offset With No Date Will Cause The Command To Be Executed Once
For Each File That Is (@+) > The System Date Plus The Offset, OR
For Each File That Is (@-) < The System Date Minus The Offset.
Date and Offset:
Operates upon files whose file date fall between the Date and The Date
plus the Offset, or the Date and the Date minus the Offset.
Entering A Date And An Offset Will Cause The Command To Be Executed Once
For Each File That Is (@+) > The Date AND < The Date Plus Offset, OR
For Each File That Is (@-) < The Date AND > The Date Minus Offset.
Examples:
Cmddate DEL C:\*.DOC @+ 3/15/93 Deletes *.DOC > 3/15/93
Cmddate DEL C:\*.PRN @- 3/15/93 Deletes *.PRN < 3/15/93
Cmddate DEL C:\*.BAK @-5 Deletes *.BAK < System Date Minus 5
Cmddate DEL C:\*.TXT @-5 3/15/93 Deletes *.TXT < 3/15/93 AND > 3/10/93
Cmddate DEL c:\*.SYS @+5 3/15/93 Deletes *.SYS > 3/15/93 AND < 3/20/93
Cmddate COPY *.* C:\DIR @+ 3/15/93 Copies All Files With Dates > 3/15/93
To C:\DIR\
Cmddate REN *.TXT *.BAK @+5 3/15/93 Renames All *.TXT With Dates
> 3/15/93 AND < 3/20/93 To *.BAK
Limitations:
Command-Date has several limitations. The 128 character command line
length imposed by dos limits the length of the Command-Date command
line. That same limitation limits the length of the command line that
Command-Date can issue to dos in executing a command. Some of the
functions of the Borland C compiler that was used has a maximum path
of 80 characters. Command-date uses these function to build file paths,
so the file specs that Command-Date passes to the Command as the first
parameter cannot exceed 80 characters. This could be a problem on hard
drives with lots of long subdirectory names.
When using the include subdirectories option, Command-Date
stores pending subdirectory paths on a last-in first-out, dynamically
allocated memory stack. It is limited to a maximum of 500 entries,
with a maximum of 80 characters in length. This should handle most hard
drives with no problem.
Valid dates are from 1-1-81 to 12-31-99. These limits are
imposed on the sum of the date and the offset. Entering a date and
offset combination that results in a test date outside these limits
will give a date out of range error.
The /N requires an AT computer with a extended (101) keyboard.
It will not work on an XT computer because the bios calls used to write
to the keyboard are not supported by the XT bios or by 84 key keyboards.
Dos commands known to work with Command-Date:
Del use normal single parameter with wildcards.
Dir use normal single parameter with wildcards, use /T to get better listing
Copy use normal source and destination parameters with wildcards.
Ren use normal current filename and new filename parameters with wildcards.
Comp use Command-Date's /N switch to answer no to the more files? prompt.
Backup use Backup's /A switch to append files of a selected date.
use the /S switch with all the above to include all subdirectories.
Purpose and Usefulness:
The reason for writing this program was simply because I
needed a utility to delete all files with a specific extension that were
over three days old. These files were being downloaded daily from a
mainframe host into many subdirectories on a network drive. The
files were updated regularly on the host and the operators were supposed
to delete the local files each time they were used , to assure
that we were always using up to date files. Often files didn't get
deleted and after a few weeks hundreds of out of date files would
accumulate. It was very time consuming to delete these files
individually. Some disk utilities helped but it was still a slow
process. I could not find any utilities that would help with this
problem. No one but me seemed to be concerned with file dates so I
decided to do it myself.
While writing I decided not to restrict it's usage, just to
deletion. I tried to make it as versatile as possible. Although A large
part of the code is devoted to command line interpretation and
validation, any executable file can be entered for the Command and any
number of parameters can be passed directly to that command as second,
third, ect parameters. The include subdirectory option by itself is a
useful extension to the delete, rename, and copy commands. By setting
the date selection to less than tomorrow and invoking the /S option,
these dos commands can be used to globally delete, rename, or copy
entire hard drives with one command.
There are probably many executable files that will be useful when
run with Command-Date. Feel free to Use it, experiment with it, and
share it with your friends. I spent many hours on this program (I am
an amateur programmer and this is my first "C" program of any
significance) and I had rather see it used than just taking up disk
space. I'd be interested in knowing if anyone finds any bugs, has any
suggestions for improvements, is using it in any unusual applications,
or has found any useful executable to be ran with Command-Date. I can
be contacted at my home phone or address, or through electronic mail on
compuserv. My address, phone, and compuserv id are listed at the beginning
of this document. I hope that this program will make someone else's hard
drive maintenance a little easer.